home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / o-z / x-windows / mesa-amiwin / src / dd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  9.3 KB  |  265 lines

  1. /* dd.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Id: dd.h,v 1.20 1995/11/10 20:42:57 brianp Exp $
  26.  
  27. $Log: dd.h,v $
  28.  * Revision 1.20  1995/11/10  20:42:57  brianp
  29.  * removed old comments
  30.  *
  31.  * Revision 1.19  1995/10/30  15:30:48  brianp
  32.  * added mask[] argument to read_[color|index]_pixels
  33.  *
  34.  * Revision 1.18  1995/10/19  15:46:31  brianp
  35.  * changed clear_color and color arguments to GLubytes
  36.  *
  37.  * Revision 1.17  1995/10/17  21:43:22  brianp
  38.  * finished changes for new device driver interface
  39.  *
  40.  * Revision 1.16  1995/09/21  14:07:55  brianp
  41.  * more new DD prototyping
  42.  *
  43.  * Revision 1.15  1995/09/20  18:19:58  brianp
  44.  * prototype device driver changes described
  45.  *
  46.  * Revision 1.14  1995/09/15  18:46:39  brianp
  47.  * new functions pointers for all device driver functions
  48.  *
  49.  * Revision 1.13  1995/07/24  18:55:20  brianp
  50.  * added dd_finish()
  51.  *
  52.  * Revision 1.12  1995/06/12  15:38:23  brianp
  53.  * changed color arrays to GLubyte
  54.  *
  55.  * Revision 1.11  1995/05/22  20:59:34  brianp
  56.  * Release 1.2
  57.  *
  58.  * Revision 1.10  1995/04/12  15:37:05  brianp
  59.  * removed dd_draw_pixel(), dd_draw_line(), and dd_draw_polygon()
  60.  *
  61.  * Revision 1.9  1995/04/11  14:04:57  brianp
  62.  * introduced DD struct of function pointers
  63.  *
  64.  * Revision 1.8  1995/03/30  21:07:49  brianp
  65.  * updated to use pointers to CC.write_* functions
  66.  *
  67.  * Revision 1.7  1995/03/22  21:36:53  brianp
  68.  * removed mode from dd_buffer_info()
  69.  *
  70.  * Revision 1.6  1995/03/08  15:10:02  brianp
  71.  * added support for dd_logicop
  72.  * added dd_clear_index and dd_clear_color
  73.  *
  74.  * Revision 1.5  1995/03/07  19:01:39  brianp
  75.  * added dd_read_index_pixels() and dd_read_color_pixels()
  76.  *
  77.  * Revision 1.4  1995/03/07  14:20:41  brianp
  78.  * updated for new XSetForeground/GC scheme
  79.  *
  80.  * Revision 1.3  1995/03/04  19:25:29  brianp
  81.  * 1.1 beta revision
  82.  *
  83.  * Revision 1.2  1995/02/27  22:48:36  brianp
  84.  * modified for PB
  85.  *
  86.  * Revision 1.1  1995/02/24  14:20:25  brianp
  87.  * Initial revision
  88.  *
  89.  */
  90.  
  91.  
  92. #ifndef DD_INCLUDED
  93. #define DD_INCLUDED
  94.  
  95.  
  96. #include "context.h"
  97.  
  98.  
  99. /*
  100.  *                      Device Driver (DD) interface
  101.  *
  102.  *
  103.  * All device driver functions are accessed via pointers in the global
  104.  * DD struct.  The pointers in this struct must be initialized by the
  105.  * Mesa/window system interface (xmesa.c for example).
  106.  *
  107.  * Many of the pointers can be initialized once then forgotten.  Others
  108.  * may have to be reassigned depending on the frame buffer configuration.
  109.  *
  110.  * For example, in the X/Mesa driver there are many pixel span writing
  111.  * functions, each optimized for a specific visual or pixmap/ximage config-
  112.  * uration.  These function pointers have to be updated whenever the
  113.  * glDrawBuffer() function is called.
  114.  *
  115.  * The reason we use function pointers is to:
  116.  *   1. allow switching between a number of different device drivers at
  117.  *      runtime.
  118.  *   2. use optimized functions dependend on frame buffer configuration
  119.  *
  120.  * 
  121.  * Here's a quick description of each device driver function's purpose:
  122.  *
  123.  * finish - implements glFinish()
  124.  * flush - implements glFlush()
  125.  * clear_index - implements glClearIndex()
  126.  * clear_color - implements glClearColor()
  127.  * clear - implements glClear(), with some special arguments
  128.  * index - implements glIndex()
  129.  * index_mask - implements glIndexMask() if possible, else return GL_FALSE
  130.  * color - implements glColor()
  131.  * color_mask - implements glColorMask() if possible, else return GL_FALSE
  132.  * logicop - implements glLogicOp() if possible, else return GL_FALSE
  133.  * dither - enable/disable dithering
  134.  *
  135.  * set_buffer - selects the front or back buffer for reading and writing.
  136.  *              The default value is the buffer selected for writing pixels.
  137.  *              When pixels have to be read from the color buffer, the core
  138.  *              library will  call this function to temporarily select the
  139.  *              "read" buffer, then restore it to the "draw" buffer.
  140.  *
  141.  * buffer_size - return width, height, depth of image buffer
  142.  *
  143.  * These functions provide the interface to "accelerated" rendering.  Each
  144.  * function should return a pointer to an accelerated point, line, or
  145.  * polygon function if one exists, otherwise return NULL.  When one of these
  146.  * functions is called, the device driver must analyze the current GL state
  147.  * to determine if it can draw an accelerated primitive.
  148.  * 
  149.  * get_points_func - return pointer to a point drawing function or NULL.
  150.  * get_lines_func - return pointer to a line drawing function or NULL.
  151.  * get_polygon_func - return pointer to a polygon drawing function or NULL.
  152.  *
  153.  * write_color_span - write a horizontal run of RGBA pixels
  154.  * write_monocolor_span - write a horizontal run of mono-RGBA pixels
  155.  * write_color_pixels - write a random array of RGBA pixels
  156.  * write_monocolor_pixels - write a random array of mono-RGBA pixels
  157.  *
  158.  * write_index_span - write a horizontal run of CI pixels
  159.  * write_nonoindex_span - write a horizontal run of mono-CI pixels
  160.  * write_index_pixels - write a random array of CI pixels
  161.  * write_monoindex_pixels - write a random array of mono-CI pixels
  162.  *
  163.  * read_index_span - read a horizontal run of color index pixels
  164.  * read_color_span - read a horizontal run of RGBA pixels
  165.  * read_index_pixels - read a random array of CI pixels
  166.  * read_color_pixels - read a random array of RGBA pixels
  167.  *
  168.  * NOTES:
  169.  *   RGBA = red/green/blue/alpha
  170.  *   CI = color index (color mapped mode)
  171.  *   mono = all pixels have the same color or index
  172.  *
  173.  *   The write_ functions all take an array of mask flags which indicate
  174.  *   whether or not the pixel should be written.  One special case exists
  175.  *   in the write_color_span function: if the mask array is NULL, then
  176.  *   draw all pixels.  This is an optimization used for glDrawPixels().
  177.  *
  178.  * IN ALL CASES:
  179.  *      X coordinates start at 0 at the left and increase to the right
  180.  *      Y coordinates start at 0 at the bottom and increase upward
  181.  */
  182.  
  183.  
  184.  
  185. struct dd_function_table {
  186.  
  187.    /*
  188.     * Functions for implementing basic GL operations:
  189.     */
  190.    void (*finish)( void );
  191.    void (*flush)( void );
  192.  
  193.    void (*clear_index)( GLuint index );
  194.    void (*clear_color)( GLubyte red, GLubyte green,
  195.                         GLubyte glue, GLubyte alpha );
  196.    void (*clear)( GLboolean all, GLint x, GLint y, GLint width, GLint height );
  197.  
  198.    void (*index)( GLuint index );
  199.    void (*color)( GLubyte red, GLubyte green, GLubyte glue, GLubyte alpha );
  200.    GLboolean (*index_mask)( GLuint mask );
  201.    GLboolean (*color_mask)( GLboolean rmask, GLboolean gmask,
  202.                             GLboolean bmask, GLboolean amask );
  203.  
  204.    GLboolean (*logicop)( GLenum op );
  205.  
  206.    void (*dither)( GLboolean enable );
  207.  
  208.    GLboolean (*set_buffer)( GLenum mode );
  209.  
  210.    void (*buffer_size)( GLuint *width, GLuint *height, GLuint *depth );
  211.  
  212.    /*
  213.     * Return pointers to accelerated point, line, polygon rendering functions:
  214.     */
  215.    points_func (*get_points_func)( void );
  216.    line_func (*get_line_func)( void );
  217.    polygon_func (*get_polygon_func)( void );
  218.  
  219.    /*
  220.     * Functions for writing pixels to the frame buffer:
  221.     */
  222.    void (*write_color_span)( GLuint n, GLint x, GLint y,
  223.                  const GLubyte red[], const GLubyte green[],
  224.                  const GLubyte blue[], const GLubyte alpha[],
  225.                  const GLubyte mask[] );
  226.    void (*write_monocolor_span)( GLuint n, GLint x, GLint y,
  227.                  const GLubyte mask[] );
  228.    void (*write_color_pixels)( GLuint n, const GLint x[], const GLint y[],
  229.                    const GLubyte red[], const GLubyte green[],
  230.                    const GLubyte blue[], const GLubyte alpha[],
  231.                    const GLubyte mask[] );
  232.    void (*write_monocolor_pixels)( GLuint n, const GLint x[], const GLint y[],
  233.                    const GLubyte mask[] );
  234.    void (*write_index_span)( GLuint n, GLint x, GLint y, const GLuint index[],
  235.                  const GLubyte mask[] );
  236.    void (*write_monoindex_span)( GLuint n, GLint x, GLint y,
  237.                  const GLubyte mask[] );
  238.    void (*write_index_pixels)( GLuint n, const GLint x[], const GLint y[],
  239.                    const GLuint index[], const GLubyte mask[] );
  240.    void (*write_monoindex_pixels)( GLuint n, const GLint x[], const GLint y[],
  241.                    const GLubyte mask[] );
  242.  
  243.    /*
  244.     * Functions to read pixels from frame buffer:
  245.     */
  246.    void (*read_index_span)( GLuint n, GLint x, GLint y, GLuint index[] );
  247.    void (*read_color_span)( GLuint n, GLint x, GLint y,
  248.                 GLubyte red[], GLubyte green[],
  249.                 GLubyte blue[], GLubyte alpha[] );
  250.    void (*read_index_pixels)( GLuint n, const GLint x[], const GLint y[],
  251.                   GLuint indx[], const GLubyte mask[] );
  252.    void (*read_color_pixels)( GLuint n, const GLint x[], const GLint y[],
  253.                   GLubyte red[], GLubyte green[],
  254.                   GLubyte blue[], GLubyte alpha[],
  255.                               const GLubyte mask[] );
  256. };
  257.  
  258.  
  259.  
  260. extern struct dd_function_table DD;
  261.  
  262.  
  263. #endif
  264.  
  265.